package com.jiayang.hhotel.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.bean.ContractDisCountModel;
import com.yanzhenjie.recyclerview.swipe.SwipeMenuAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/5/26 0016.
 * 合同折扣列表适配器
 */

public class ContractDisCountListAdapter extends SwipeMenuAdapter<ContractDisCountListAdapter.ViewHolder> {

//    private static final int TYPE_ITEM =0; //普通Item View
//    private static final int TYPE_FOOTER = 1; // 底部FootView

    private List<ContractDisCountModel.PTaContractDisListDtoBean> mList;
    private Context t;


    public ContractDisCountListAdapter(Context context, List<ContractDisCountModel.PTaContractDisListDtoBean> list){
        this.mList=list;
        this.t=context;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ContractDisCountModel.PTaContractDisListDtoBean model=mList.get(position);
//        holder.contractDate.setText(t.getString(R.string.start_date)+t.getString(R.string.space)+model.);
        holder.AccountGroup.setText(t.getString(R.string.account_group)+t.getString(R.string.space)+model.getTrnGroup());
        holder.TuanHui.setText(t.getString(R.string.tuanhui_discount)+t.getString(R.string.space)+model.getGrpDiscount());
        holder.SanKe.setText(t.getString(R.string.sanke_discount)+t.getString(R.string.space)+model.getGstDiscount());
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    @Override
    public View onCreateContentView(ViewGroup parent, int viewType) {
        return LayoutInflater.from(t).inflate(R.layout.contract_discount_list_item, parent, false);
    }

    @Override
    public ViewHolder onCompatCreateViewHolder(View realContentView, int viewType) {
        return new ViewHolder(realContentView);
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        TextView contractDate;//合同区间
        TextView AccountGroup;//帐组
        TextView TuanHui;//团会折扣
        TextView SanKe;//散客折扣

        public ViewHolder(View convertView) {
            super(convertView);
            contractDate= (TextView) convertView.findViewById(R.id.tv_date);
            AccountGroup= (TextView) convertView.findViewById(R.id.tv_account_group);
            TuanHui= (TextView) convertView.findViewById(R.id.tv_tuanhui_discount);
            SanKe= (TextView) convertView.findViewById(R.id.tv_sanke_discount);
        }
    }
}
